Skip to main content
Access via:io.prefs

App Preferences API.

11 Methods

clear()⚓︎

() => Promise<void>

Removes the user preferences for the current app.

clearAll()⚓︎

() => Promise<void>

Removes all preferences stored for the current user.

clearFor()⚓︎

(app: string) => Promise<void>

Removes the user preferences for a specified app.

Parameters (1)

Name Type Required Description
app⚓︎ string

Name of the app whose user preferences to remove.

get()⚓︎

(app?: string) => Promise<AppPreferences | undefined>

Retrieves the user preferences for the current app.

Parameters (1)

Name Type Required Description
app⚓︎ string x

Name of the app for which to retrieve the user preferences.

getAll()⚓︎

() => Promise<{ all: AppPreferences[]; }>

Retrieves all preferences stored for the current user.

set()⚓︎

(data: Data, options?: { app: string }) => Promise<void>

Replaces the user preferences for the current app. All existing properties will be removed and replaced with the ones supplied in the data object.

Parameters (2)

Name Type Required Description
data⚓︎ Data

Data to replace the existing user preferences.

options⚓︎ { app: string } x

Object with an app property that accepts an app name as a value. Can be used to target a specific app whose user preferences to replace.

setFor()⚓︎

(app: string, data: Data) => Promise<void>

Replaces the user preferences of a specified app. All existing properties will be removed and replaced with the ones supplied in the data object.

Parameters (2)

Name Type Required Description
app⚓︎ string

Name of the app whose user preferences to replace.

data⚓︎ Data

Data to replace the existing user preferences.

subscribe()⚓︎

(callback: (prefs: AppPreferences) => void) => () => void

Subscribes for changes to the user preferences of the current app.

Parameters (1)

Name Type Required Description
callback⚓︎ (prefs: AppPreferences) => void

Callback function that will be invoked once with the initial user preferences and after that on every change of the user preferences.

subscribeFor()⚓︎

(app: string, callback: (prefs: AppPreferences) => void) => () => void

Subscribes for changes to the user preferences of a specified app.

Parameters (2)

Name Type Required Description
app⚓︎ string

Name of the app to which to subscribe.

callback⚓︎ (prefs: AppPreferences) => void

Callback function that will be invoked once with the initial user preferences and after that on every change of the user preferences.

update()⚓︎

(data: Data, options?: { app: string }) => Promise<void>

Updates the preferences for the current app. The properties specified in the data object will be merged with the existing user preferences. Other existing properties will remain intact, and non-existent ones will be added.

Parameters (2)

Name Type Required Description
data⚓︎ Data

Data to be merged with the existing user preferences.

options⚓︎ { app: string } x

Object with an app property that accepts an app name as a value. Can be used to target a specific app whose user preferences to update.

updateFor()⚓︎

(app: string, data: Data) => Promise<void>

Updates the preferences for a specified app. The properties specified in the data object will be merged with the existing user preferences. Other existing properties will remain intact, and non-existent ones will be added.

Parameters (2)

Name Type Required Description
app⚓︎ string

Name of the app whose user preferences to update.

data⚓︎ Data

Data to be merged with the existing user preferences.